package com.bitoon.basketdudes.web.jpa;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;

@Entity
@Table(name = "activacion", schema="central")
@NamedQueries({
    //@NamedQuery(name = "Activacion.findAll", query = "SELECT a FROM Activacion a"),
    @NamedQuery(name = "Activacion.findByEmailValor", query = "SELECT a FROM Activacion a WHERE a.usuario.email = :email and a.valor = :valor"),
    @NamedQuery(name = "Activacion.findByNickValor", query = "SELECT a FROM Activacion a WHERE a.usuario.nick = :nick and a.valor = :valor"),
    @NamedQuery(name = "Activacion.findByHashUsuarioId", query = "SELECT a FROM Activacion a WHERE a.usuario.id = :idUsuario AND a.hash = :hash")
    /*
    @NamedQuery(name = "Activacion.findByHash", query = "SELECT a FROM Activacion a WHERE a.hash = :hash"),
    @NamedQuery(name = "Activacion.findByFAlta", query = "SELECT a FROM Activacion a WHERE a.fAlta = :fAlta"),
    @NamedQuery(name = "Activacion.findByTipo", query = "SELECT a FROM Activacion a WHERE a.tipo = :tipo"),
    @NamedQuery(name = "Activacion.findByValor", query = "SELECT a FROM Activacion a WHERE a.valor = :valor")
     *
     */
})

  public class Activacion implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "hash")
    private String hash;
    @Basic(optional = false)
    @Column(name = "f_alta")
    @Temporal(TemporalType.TIMESTAMP)
    private Date fAlta = new Date();
    @Basic(optional = false)
    @Column(name = "tipo")
    private int tipo = 0;
    @Column(name = "valor")
    private String valor;
    @Basic(optional = false)
    @Column(name = "status")
    private int status = 0;

    @ManyToOne
    @JoinColumn(name = "usuario_id", referencedColumnName = "id")
    private Usuario usuario;

    public Activacion() {
    }

    public Activacion(String hash) {
        this.hash = hash;
    }

    public Activacion(String hash, Date fAlta, int tipo) {
        this.hash = hash;
        this.fAlta = fAlta;
        this.tipo = tipo;
    }

    public String getHash() {
        return hash;
    }

    public void setHash(String hash) {
        this.hash = hash;
    }

    public Date getFAlta() {
        return fAlta;
    }

    public void setFAlta(Date fAlta) {
        this.fAlta = fAlta;
    }

    public int getTipo() {
        return tipo;
    }

    public void setTipo(int tipo) {
        this.tipo = tipo;
    }

    public String getValor() {
        return valor;
    }

    public void setValor(String valor) {
        this.valor = valor;
    }

    @Override
    public int hashCode() {
        int lhash = 0;
        lhash += (hash != null ? hash.hashCode() : 0);
        return lhash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Activacion)) {
            return false;
        }
        Activacion other = (Activacion) object;
        if ((this.hash == null && other.hash != null) || (this.hash != null && !this.hash.equals(other.hash))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bitoon.basketdudes.web.jpa.Activacion[hash=" + hash + "]";
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

}
